package com.xiandou.server.config;

import com.ctrip.framework.apollo.model.ConfigChange;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.util.Set;

/**
 * @Author: wu.peng
 * @Date: 2020/1/3 3:55 PM
 */
@Configuration
@EnableApolloConfig(value = "test-namespace",order = 1)
public class MyConfig {

    @Value("${name}")
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @ApolloConfigChangeListener(value = "test-namespace")
    private void changeEvent(ConfigChangeEvent changeEvent) {
        Set<String> strings = changeEvent.changedKeys();
        ConfigChange name = changeEvent.getChange("name");
    }

}
